package com.itheima.day15.TCP.test4;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

public class ClientDemo {
    public static void main(String[] args) throws IOException {
        Socket s = new Socket("10.254.1.79",10005);

        OutputStream os = s.getOutputStream();
        os.write("你好".getBytes());
        s.shutdownOutput();

        InputStream is = s.getInputStream();
        byte[] bytes = new byte[1024];
        int len;
        while((len = is.read(bytes)) != -1){
            System.out.println(new String(bytes,0,len));
        }

        is.close();
        s.close();
    }
}
